
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel=stylesheet href='include/hoj.css' type='text/css'>
</head>
<body>
<center>
<div style="width:90%; text-align:left">
<img src="image/logo.png"/>
</div>
<table width=96%> 
	<tr align="center" class='hd' valign="top">
				<th><a href="faqs.php">F.A.Qs</a></th>
		<th><a href="./bbs.php">Web Board</a></th>
		<th><a href="./">Home</a></th>
		<th><a href="./problemset.html">ProblemSet</a></th>
		<th><a href="./status.php">Status</a></th>
		<th><a href="./ranklist.php">Ranklist</a></th>
		<th><a href="./contest.php">Contest</a></th>
		<th><a href=loginpage.php>Login</a></th><th><a href=registerpage.php>Register</a></th>	</tr>
</table>
</center>
<center>
<div class="notice">
	<div>
		<B>Notice:</B>鉴于种种原因，本OJ自下周星期一（3月5号）开始不再全面开放，请各位做好善后事宜，谢谢合作。	</div>
</div>
</center>
</div>
<title>Problem 2500. -- 幸福的道路 -- 衡阳八中OJ离线版-2012-02-29</title><center><h2>2500: 幸福的道路</h2><span class=green>Time Limit: </span>20 Sec&nbsp;&nbsp;<span class=green>Memory Limit: </span>256 MB<br><span class=green>Submit: </span>76&nbsp;&nbsp;<span class=green>Solved: </span>34<br>[<a href='submitpage.php?id=2500'>Submit</a>][<a href='problemstatus.php?id=2500'>Status</a>][<a href='bbs.php?id=2500'>Discuss</a>]</center><h2>Description</h2><div class=content><div></div>
<div><span style="font-size: medium">小T与小L终于决定走在一起,他们不想浪费在一起的每一分每一秒,所以他们决定每天早上一同晨练来享受在一起的时光.</span></div>
<div><span style="font-size: medium">他们画出了晨练路线的草图,眼尖的小T发现可以用树来描绘这个草图.</span></div>
<div><span style="font-size: medium">他们不愿枯燥的每天从同一个地方开始他们的锻炼,所以他们准备给起点标号后顺序地从每个起点开始(第一天从起点一开始,第二天从起点二开始&hellip;&hellip;). 而且他们给每条道路定上一个幸福的值.很显然他们每次出发都想走幸福值和最长的路线(即从起点到树上的某一点路径中最长的一条).</span></div>
<div><span style="font-size: medium">他们不愿再经历之前的大起大落,所以决定连续几天的幸福值波动不能超过M(即一段连续的区间并且区间的最大值最小值之差不超过M).他们想知道要是这样的话他们最多能连续锻炼多少天(hint:不一定从第一天一直开始连续锻炼)?</span></div>
<div><span style="font-size: medium">现在，他们把这个艰巨的任务交给你了!</span></div></div><h2>Input</h2><div class=content><div><span style="font-size: medium">第一行包含两个整数N, M(M&lt;=10^9).</span></div>
<div><span style="font-size: medium">第二至第N行,每行两个数字Fi , Di, 第i行表示第i个节点的父亲是Fi,且道路的幸福值是Di.</span></div></div><h2>Output</h2><div class=content><div><span style="font-size: medium">最长的连续锻炼天数</span></div></div><h2>Sample Input</h2>
			<div class=content><span class=sampledata>3 2<br />
1 1<br />
1 3<br />
</span></div><h2>Sample Output</h2>
			<div class=content><span class=sampledata>3<br />
数据范围：<br />
50%的数据N<=1000<br />
80%的数据N<=100 000<br />
100%的数据N<=1000 000<br />
 </span></div><h2>HINT</h2>
			<div class=content><p></p></div><h2>Source</h2>
			<div class=content><p><a href='problemset.html?search='></a></p></div><center>[<a href='submitpage.php?id=2500'>Submit</a>][<a href='problemstatus.php?id=2500'>Status</a>][<a href='bbs.php?id=2500'>Discuss</a>]</center>﻿<br>

<a href="./"><span class=red>HOME</span></a>
<a href="javascript:history.go(-1)"><span class=red>Back</span></a>

<hr>
<center>
	<div class="footer">
			<a href=setlang.php?lang=ko>한국어</a>&nbsp;
		<a href=setlang.php?lang=cn>中文</a>&nbsp;
		<a href=setlang.php?lang=fa>فارسی</a>&nbsp;
		<a href=setlang.php?lang=en>English</a>&nbsp;
		<a href=setlang.php?lang=th>ไทย</a>
	<br>		<div>版权所有 &copy;2008-2012 WaterPark Organization. | <script src="http://s21.cnzz.com/stat.php?id=2982771&web_id=2982771" language="JavaScript"></script>
</div>
		<div>Based on opensource project <a href="http://hustoj.googlecode.com">hustoj</a>.</div>
	</div>
</center>
</body>
</html>
